package com.rhtchr.angelbaby.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;

@Entity
@Table(name = "v_article")
public class VArticle {

	private int topicId;
	private int articleId;
	// 作者
	private String author;
	// 文章创建时间
	private Date insertTime;
	// 标题
	private String title;
	// 摘要
	private String summary;
	private int id;
	// 子标题或者父标题
	private String subtitle;

	@Column(name = "article_id", insertable = false, updatable = false)
	public int getArticleId() {
		return articleId;
	}

	/**
	 * 返回文章的作者。如果没有录入文章的作者，那么默认为“佚名”。
	 * 
	 * @return
	 */
	@Column(name = "author_name", length = 64, insertable = false, updatable = false)
	public String getAuthor() {
		if (StringUtils.isEmpty(author)) {
			author = "佚名";
		}
		return author;
	}

	@Id
	@Column(name = "id", insertable = false, updatable = false)
	public int getId() {
		return id;
	}

	@Column(name = "insert_time", insertable = false, updatable = false)
	public Date getInsertTime() {
		return insertTime;
	}

	@Column(name = "article_summary", length = 4096, insertable = false, updatable = false)
	public String getSummary() {
		return summary;
	}

	@Column(name = "article_title", length = 1024, insertable = false, updatable = false)
	public String getTitle() {
		return title;
	}

	@Column(name = "topic_id", insertable = false, updatable = false)
	public int getTopicId() {
		return topicId;
	}

	public void setArticleId(int articleId) {
		this.articleId = articleId;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setInsertTime(Date insertTime) {
		this.insertTime = insertTime;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setTopicId(int topicId) {
		this.topicId = topicId;
	}

	@Column(name = "article_sub_title", length = 1024)
	public String getSubtitle() {
		return subtitle;
	}

	public void setSubtitle(String subtitle) {
		this.subtitle = subtitle;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

}
